<?php

namespace app\admin\controller;

use think\facade\Session;
use app\admin\controller\Base;
use app\common\model\SmsLog as SmsLogModel;

class SmsLog extends Base
{
    public function initialize()
    {
        parent::initialize();
        $this->Model = new SmsLogModel();
    }

    public function export(){
        $param = $this->request->param();
        $default_param = $this->index_default_param();
        $this->Model->exportExcel(array_merge($param, $default_param));
    }

    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function read($id = 0)
    {
        $select_fields = [
            "*",
            "IF(request_ip!='' && request_ip>0, INET_NTOA(request_ip), '') AS client_ip"
        ];
        $log = $this->Model->field($select_fields)->where("id", $id)->find();
        if(empty($log)){
            $this->redirect('index');
        }
        $this->assign('log', $log);
        return $this->fetch();
    }
}
